package com.cy.common.Advice;

import com.cy.common.Exception.ServiceException;
import com.cy.web.pojo.LogResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
   // private static final Logger log=LoggerFactory.getLogger(GlobalExceptionHandler.class);
    @ExceptionHandler(RuntimeException.class)
    public LogResult doHandRunTimeException(RuntimeException e){
        e.printStackTrace();
        log.error("exception msg is {}",e.getMessage());
        return new LogResult(e);
    }
    @ExceptionHandler(ServiceException.class)
    public LogResult doHandServiceException(ServiceException e){
        e.printStackTrace();
        log.error("exception msg is {}",e.getMessage());
        return new LogResult(e);
    }
}
